﻿using System;
using System.Data;

namespace AuctionSite.Entities
{
    public class Lance : IEntity<Lance>
    {

        #region Propriedades

        public int Id { get; set; }
        public int UsuarioId { get; set; }
        public int ProdutoId { get; set; }
        public decimal Valor { get; set; }
        public DateTime Data { get; set; }

        #endregion

        public Lance Load(DataRow row)
        {
            if (row != null)
            {
                if (!string.IsNullOrEmpty(row["lance_id"].ToString()))
                {
                    this.Id = Convert.ToInt16(row["lance_id"]);
                    this.UsuarioId = Convert.ToInt16(row["usu_id"]);
                    this.ProdutoId = Convert.ToInt16(row["prod_id"]);
                    this.Valor = Convert.ToDecimal(row["lance_valor"]);
                    this.Data = string.IsNullOrEmpty(row["lance_hora"].ToString()) ? DateTime.MinValue : Convert.ToDateTime(row["lance_hora"]);
                }
            }

            return this;
        }
    }
}